home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: techfak.uni-bielefeld.de!isthesin
- From: isthesin@techfak.uni-bielefeld.de (Stephan Thesing)
- Subject: Re: Must I free my linked lists? (GCC)
- Message-ID: <DLoIKE.I29@hermes.hrz.uni-bielefeld.de>
- Sender: isthesin@TechFak.Uni-Bielefeld.DE (Stephan Thesing)
- Date: Wed, 24 Jan 1996 09:33:49 GMT
- References: <4dudic$aif@vixen.cso.uiuc.edu> <4dusp9$7k3@senator-bedfellow.MIT.EDU>
- Nntp-Posting-Host: moos.techfak.uni-bielefeld.de
- Organization: Universitaet Bielefeld, Technische Fakultaet.
- X-Newsreader: xrn 8.01
-
- In article <4dusp9$7k3@senator-bedfellow.MIT.EDU>, rid@red-branch.MIT.EDU (Shawna Grimm) writes:
- |> Unknown (Dannyman@uiuc.edu) typed in the following on 21 Jan 1996 22:09:16 GMT:
- |> : I'm writing a program that makes use of dynamic memory allocation through
- |> : linked lists using malloc() ... from an implementation PoV there's no need
- |> : to flush this stuff as after the queue is created it's output and the
- |> : program exits. My question is;
- |>
- |> : "When my program exits, is the dynamic memory in the queues returned to
- |> : the system or is a "memory hole" left, so that I should actually go back and
- |> : return all the memory in my program ..."
- |>
- |> Yes, you _should_ free any memory that you allocate in your program.
- |> Memory that is allocated and not freed will not be returned to the system
- |> unless you turn the machine off, so if you want your memory back, you
- |> must free it. Personally, I would prefer to use AllocMem() or AllocVec()
- |> (with FreeMem() and FreeVec() ofcourse).
- |>
-
- This is true, but normally memory allocated via malloc() is freed automatically
- by the exit code of the program.
- malloc() and free() differ from AllocMem()/FreeMem() (AllocVec()...) in this point.
- The startup (and exit) code that is linked in with gcc (crt0.o) does the
- necessary cleanup at exit (in conjunction with ixemul.library).
- Bye...
- Stephan
-
-
-
-
-
- |> : Thanks. Please reply publically, because I got 20 emails on my last
- |> : question. No *need* for all you courteous folk to respond! :)
- |>
- |> : --
- |> * Lars M. Hansen
-
- --
- ===============================================
- = Stephan Thesing =
- = AG Praktische Informatik =
- = Technische Fakult"at =
- = Universit"at Bielefeld =
- ===============================================
-